<template>
  <div class="mod-home">
    <el-row :gutter="10" style="margin-bottom: 10px;">
      <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>平台总交易额</span>
            <el-tag style="float: right;" size="mini" >元</el-tag>
          </div>
          <div class="item-number">
            ￥<countTo :startVal="0" :endVal='Number(total.total_settle_money)' :decimals="2" :duration="700"></countTo>
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>昨日交易额</span>
            <el-tag style="float: right;" size="mini" >元</el-tag>
          </div>
          <div class="item-number">
            ￥<countTo :startVal="0" :endVal='Number(total.yesterday_settle_money)' :decimals="2" :duration="700"></countTo>
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>近七日交易总额</span>
            <el-tag style="float: right;" size="mini" >元</el-tag>
          </div>
          <div class="item-number">
            ￥<countTo :startVal="0" :endVal="Number(total.sevenday_settle_money)" :decimals="2" :duration="700"></countTo>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>用户总览</span>
      </div>
      <div class="section">
        <div class="user-overview">
          <div class="item">
            <div class="number">{{total.today_member_add_num + total.today_company_add_num}}</div>
            <div class="name">今日新增</div>
            <div class="detail">
              <span>
                自然人
                <span class="danger-text">{{total.today_member_add_num}}</span>
              </span>
              <span>
                企业
                <span class="danger-text">{{total.today_company_add_num}}</span>
              </span>
            </div>
          </div>
          <div class="item">
            <div class="number">{{total.yesterday_member_add_num + total.yesterday_company_add_num}}</div>
            <div class="name">昨日新增</div>
            <div class="detail">
              <span>
                自然人
                <span class="danger-text">{{total.yesterday_member_add_num}}</span>
              </span>
              <span>
                企业
                <span class="danger-text">{{total.yesterday_company_add_num}}</span>
              </span>
            </div>
          </div>
          <div class="item">
            <div class="number">{{total.month_member_add_num + total.month_company_add_num}}</div>
            <div class="name">本月新增</div>
            <div class="detail">
              <span>
                自然人
                <span class="danger-text">{{total.month_member_add_num}}</span>
              </span>
              <span>
                企业
                <span class="danger-text">{{total.month_company_add_num}}</span>
              </span>
            </div>
          </div>
          <div class="item">
            <div class="number">{{total.total_member_num + total.total_company_num}}</div>
            <div class="name">用户总数</div>
            <div class="detail">
              <span>
                自然人
                <span class="danger-text">{{total.total_member_num}}</span>
              </span>
              <span>
                企业
                <span class="danger-text">{{total.total_company_num}}</span>
              </span>
            </div>
          </div>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
  import countTo from 'vue-count-to'
  export default {
    components: {
      countTo
    },
    data() {
      return {
        total:{
          total_settle_money: 0,
          yesterday_settle_money: 0,
          sevenday_settle_money: 0,
          total_member_num: 0,
          today_member_add_num: 0,
          yesterday_member_add_num: 0,
          month_member_add_num: 0,

          total_company_num: 0,
          today_company_add_num: 0,
          yesterday_company_add_num: 0,
          month_company_add_num: 0,
        },
        notices: [],
      }
    },
    mounted () {
      this.getData()
    },
    activated () {
    },
    methods: {
      jumpTourl ( _url, _id) {
        this.$router.push({ name: _url, query: { id:  _id}})
      },
      getData() {
        this.$http({
          url: this.$http.adornUrl('/sys/home'),
          method: 'get',
          params: this.$http.adornParams()
        }).then((res) => {
          let _data = res.data
          if(_data.code === 0) {
            this.total.sevenday_settle_money = _data.data.sevenday_settle_money
            this.total.total_settle_money = _data.data.total_settle_money
            this.total.yesterday_settle_money = _data.data.yesterday_settle_money

            this.total.total_member_num = _data.data.total_member_num
            this.total.today_member_add_num = _data.data.today_member_add_num
            this.total.yesterday_member_add_num = _data.data.yesterday_member_add_num
            this.total.month_member_add_num = _data.data.month_member_add_num


            this.total.total_company_num = _data.data.total_company_num
            this.total.today_company_add_num = _data.data.today_company_add_num
            this.total.yesterday_company_add_num = _data.data.yesterday_company_add_num
            this.total.month_company_add_num = _data.data.month_company_add_num
          }
        })
      }
  }
}
</script>

<style lang="scss" scoped>
.item-number {
  font-size: 30px;
  font-weight: 700;
  font-family: initial;
  color: initial;
}
.chart-box {
  min-height: 400px;
}
.section {
  margin-bottom: 15px;
}
.amount {
  .name {
    font-size: 14px;
  }
  .value {
    font-weight: bold;
    font-size: 28px;
    margin-top: 5px;
  }
}
.wait-task {
  display: flex;
  justify-content: flex-start;
  .item {
    display: flex;
    justify-content: space-between;
    width: 300px;
    margin: 20px 50px;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    padding: 15px 10px;
    .number {
      color: #f56c6c;
    }
  }
}
.user-overview {
  display: flex;
  padding: 30px 0;
  border-radius: 4px;
  border: 1px solid #eee;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  .item {
    flex: 1;
    border-left: 1px solid #eee;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    &:first-child {
      border-left: 0;
    }
    .number {
      font-size: 24px;
    }
    .name {
      font-size: 14px;
      color: #333;
      margin: 10px 0;
    }
    .detail {
      > span {
        margin: 0 20px;
      }
    }
  }
}
</style>


